package com.qf.flower_service.controller;

import com.qf.flower_service.entity.Flowers;
import com.qf.flower_service.entity.JsonResult;
import com.qf.flower_service.service.FlowersService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

import static com.qf.flower_service.entity.JsonResult.createSuccessJsonResult;

@RestController
@RequestMapping("/flower")
public class FlowersController {

    @Autowired
    private FlowersService flowersService;


    @RequestMapping("/index")
    public JsonResult findBySubarea(String subarea) {

        List<Flowers> flowersList = flowersService.findBySubarea(subarea);

        return createSuccessJsonResult(flowersList);
    }


    @RequestMapping("/select")
    public JsonResult findByNameAndType(Long detailId, String flowerName) {
        List<Flowers> FlowerList = flowersService.findByNameAndType(detailId, flowerName);
        return createSuccessJsonResult(FlowerList);

    }

}
